package com.nhjf.dao.system;

import com.nhjf.dao.BaseDao;
import com.nhjf.model.system.Organization;
import com.nhjf.pojo.qo.system.OrganizationQo;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class OrganizationDao extends BaseDao<Organization,OrganizationQo> {
    @Override
    protected Criteria buildCriteria(Criteria criteria, OrganizationQo qo) {
        if(qo!=null){
            if(qo.getAddress() != null){
                criteria.add(Restrictions.eq("address", qo.getAddress()));
            }
            if(qo.getName() != null){
                criteria.add(Restrictions.eq("name", qo.getName()));
            }
            if(qo.getOrganizationid()!=null) {
            	 criteria.add(Restrictions.eq("id", qo.getOrganizationid()));
            }
            criteria.add(Restrictions.eq("status",1));
        }
        return criteria;
    }

    @Override
    protected Class<Organization> getEntityClass() {
        return Organization.class;
    }
}
